<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="box" id="boxid">
        我是一个div盒子
    </div>
    <div id="root">
    </div>
</body>

<script>
    let arr = ['网站', '传媒', '云计算']
    let obj = {
        name: "div",//指定渲染的标签
        props: {
            class: 'box',
            id: "boxid",
            key: "1",
            children: ['我是一个div盒子', '我是一个div盒子']
        }
    }
    function renderDom(obj, root) {     
       let dom = document.createElement(obj.name)   
        if (Object.keys(obj.props)) {      
            for (let key in obj.props) {           
                if (key === "children") {
                    obj.props[key].forEach((item) => {
                        dom.innerHTML += item
                    })
                } else {              
                    dom.setAttribute(key, obj.props[key])
                }
            }
        }
        root.appendChild(dom)
    }

    renderDom(obj, root)
</script>

</html>